<?php
namespace Home\Controller;
use Think\Controller;
use Prophecy\Doubler\ClassPatch\ReflectionClassNewInstancePatch;
use Home\Service\WechatService;
use Home\Service\ClockTimeService;
// +----------------------------------------------------------------------
// | Date:2017年3月13日
// +----------------------------------------------------------------------
// | Author: EK_熊<1439527494@qq.com>
// +----------------------------------------------------------------------
// | Description: 此文件作用于****
// +----------------------------------------------------------------------
class TestController extends Controller{

    const JOINDATE = '2017-12-31';
    const SN = '0860';
    
    
    
    public function t_apply(){
        $duty_on = '2018-04-13 09:00:00';
        $duty_off = '2018-04-13 23:00:00';
        $clocktimeService = new ClockTimeService($duty_on,$duty_off);//实例化考勤类
        $a = $clocktimeService->get_intrval_work_time();
        dump($a);
        exit();
        
        $save = $clocktimeService->attendance_info([
            ['interval'=>['2018-04-13 09:00:00','2018-04-13 18:00:00'],'label'=>'leave_casual'],
//             ['interval'=>['2018-03-28 17:00:00','2018-03-28 18:00:00'],'label'=>'leave_evection'],

        ]);
//         $save = $clocktimeService->set_apply_time([])->attendance_info();
        dump($save);
    }
    
    public function t_apply_weekend(){
        $duty_on = '2018-03-05 09:00:00';
        $duty_off = '2018-03-05 10:00:00';
        $clocktimeService = new ClockTimeService($duty_on,$duty_off);//实例化考勤类
        $save = $clocktimeService->attendance_weekend([
//             ['interval'=>['2018-04-05 09:00:00','2018-04-05 12:00:00'],'label'=>'ot_weekend'],
//             ['interval'=>['2018-03-31 12:00:00','2018-03-31 15:00:00'],'label'=>'ot_weekend'],
            ['interval'=>['2018-04-05 09:00:00','2018-04-05 15:00:00'],'label'=>'leave_evection'],
//             ['interval'=>['2018-03-31 20:00:00','2018-03-31 21:00:00'],'label'=>'leave_evection'],
//             ['interval'=>['2018-03-31 10:15:00','2018-03-31 10:30:00'],'label'=>'leave_evection'],
        ]);
        dump($save);
    }
    
    public function index_daily(){
        get_vacation_name_ch(300);
    }
    
    
    public function index_yearly(){
        $anModel = D('AnnualLeave');
        dump("入职时间：".self::JOINDATE);
        dump("当前时间：".CURRENT_TIME);
        $ret = $anModel->update_yearly(self::SN,self::JOINDATE);
    }
    
    
    public function test(){
       dump($_SERVER);
    }

    public function login(){
        
        $a = $this->buildHtml('time');
      //  $a = $this->fetch('time');
        $a = html_entity_decode($a);
        $this->assign('time',$a);
        $this->display();
    }
    
    
    
 
    function quickSort(&$arr){
        if(count($arr)>1){
            $k=$arr[0];
            $x=array();
            $y=array();
            $_size=count($arr);
            for($i=1;$i<$_size;$i++){
                if($arr[$i]<=$k){
                    $x[]=$arr[$i];
                }elseif($arr[$i]>$k){
                    $y[]=$arr[$i];
                }
            }
            $x=$this->quickSort($x);
            $y=$this->quickSort($y);
            $a = array_merge($x,array($k),$y);
            dump($a);
            return $a;
        }else{
            return$arr;
        }
        
    }

    
    
}